package top.gangster.lunan.resolver;

public class FileNameResolver {

	/**
	 * 获取文件的后缀名，
	 * 例如：1234.jpg-->.jpg
	 * @param fullFileName 文件名
	 * @return 文件后缀名或""
	 */
	public static String getFileSuffix(String fullFileName) {
		if (fullFileName == null) {
			return "";
		}
		int point = fullFileName.lastIndexOf('.');
		if (point == -1) {
			return "";
		}
		return fullFileName.substring(point);
	}

	/**
	 * 获取去除文件后缀的文件名
	 * @param fullFileName 文件的全名称
	 * @return 去除文件后缀的文件名
	 */
	public static String getFileNameOffSuffix(String fullFileName) {
		if (fullFileName == null) {
			return "";
		}
		int point = fullFileName.lastIndexOf('.');
		if (point == -1) {
			return "";
		}
		return fullFileName.substring(0,point);
	}
}
